package com.ruoyi.group.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.group.domain.strokeList;
import com.ruoyi.group.service.IstrokeListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单列表Controller
 * 
 * @author yb
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/system/strokeList")
public class strokeListController extends BaseController
{
    @Autowired
    private IstrokeListService strokeListService;

    /**
     * 查询工单列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:strokeList:list')")
    @GetMapping("/list")
    public TableDataInfo list(strokeList strokeList)
    {
        startPage();
        List<strokeList> list = strokeListService.selectstrokeListList(strokeList);
        return getDataTable(list);
    }

    /**
     * 导出工单列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:strokeList:export')")
    @Log(title = "工单列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, strokeList strokeList)
    {
        List<strokeList> list = strokeListService.selectstrokeListList(strokeList);
        ExcelUtil<strokeList> util = new ExcelUtil<strokeList>(strokeList.class);
        util.exportExcel(response, list, "工单列表数据");
    }

    /**
     * 获取工单列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:strokeList:query')")
    @GetMapping(value = "/{repairId}")
    public AjaxResult getInfo(@PathVariable("repairId") Integer repairId)
    {
        return AjaxResult.success(strokeListService.selectstrokeListByRepairId(repairId));
    }

    /**
     * 新增工单列表
     */
    @PreAuthorize("@ss.hasPermi('system:strokeList:add')")
    @Log(title = "工单列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody strokeList strokeList)
    {
        return toAjax(strokeListService.insertstrokeList(strokeList));
    }

    /**
     * 修改工单列表
     */
    @PreAuthorize("@ss.hasPermi('system:strokeList:edit')")
    @Log(title = "工单列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody strokeList strokeList)
    {
        return toAjax(strokeListService.updatestrokeList(strokeList));
    }

    /**
     * 删除工单列表
     */
    @PreAuthorize("@ss.hasPermi('system:strokeList:remove')")
    @Log(title = "工单列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairIds}")
    public AjaxResult remove(@PathVariable Integer[] repairIds)
    {
        return toAjax(strokeListService.deletestrokeListByRepairIds(repairIds));
    }
}
